package com.briup.day08;

/**
 * @author lining
 * @date 2024/1/17 11:51
 */
public class TestFather2 {
    public static void main(String[] args) {
        //创建对象
        MyFather f = new MyFather();
        MySon s = new MySon();
        //使用多态创建对象
        MyFather f2 = new MySon();
        //编译看左边 运行看右边
        f.method();//father
        s.method();//son
        f2.method();//son
        System.out.println("-------");
        f.method2();
        System.out.println("-------");
        f.eat(); //father
        s.eat();//son
        f2.eat();//father

    }
}
class MyFather{
    public void method(){
        System.out.println("father");
    }
    private void say(){
        System.out.println("father");
    }
    public static void eat(){
        System.out.println("father");
    }
    public void method2(){
        MyFather f = new MyFather();
        f.say();
    }

}
class MySon extends MyFather{
    public void method(){
        System.out.println("son");
    }
    private void say(){
        System.out.println("son");
    }
    public static void eat(){
        System.out.println("son");
    }
}